#include <iostream>
using std::endl;
using std::cout;
using std::ostream;

class MyInt{
	private:
		int data;
	public:
			MyInt(int a=0): data(a){
				cout << "constructing an instance with value: \t" << data << endl;
			}

			~MyInt() {
				cout << "destructing an instance with value:\t" << data << endl;
			}

			/*
			const MyInt& operator=(const MyInt& a) {
				data=a.data;
				return *this;
			}
			*/
			
			const MyInt& operator=(const int & a) {
				data=a;
				return *this;
			}
		


		friend ostream& operator<<(ostream& os, const MyInt& t);
};


ostream& operator<<(ostream& os, const MyInt& t){
	os << t.data;
	return os;
}

int main() {

	MyInt * MyInt_ptr;
	MyInt_ptr=new MyInt[3];
	MyInt_ptr[0] = 0;
	cout << MyInt_ptr[0] << endl;
	MyInt_ptr[2] = 2;
	cout << MyInt_ptr[2] << endl;
	cout << MyInt_ptr[1] << endl;
	MyInt_ptr[1] = 1;
	cout << MyInt_ptr[1] << endl;
	delete[] MyInt_ptr;
	return 0;
}

